package ir.sourcecodes.animalsounds;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;



public class G extends Application {
    public static final int ANIMAL_NUMBER = 114;
    public static Animation alphaInfiniteAnim = null;
    public static G app = null;
    public static int appNumber = 0;
    public static Animation clickAnim = null;
    public static Animation click_anim_fast = null;
    public static Context context = null;
    public static Animation dropBounceAnim = null;
    public static Animation enterItemAnim = null;
    public static Animation enterJumpAnim = null;
    public static Animation exampleAnim = null;
    public static Animation expand1 = null;
    public static Animation expand2 = null;
    public static Animation expand3 = null;
    public static Animation expand4 = null;
    public static Animation expandBigAnim = null;
    public static Animation expandInfinite = null;
    public static Animation expandLess = null;
    public static Animation expandMore = null;
    public static Animation expandReverseFoodAnim = null;
    public static Animation fadeInAnimation = null;
    public static Animation fadeOutAnimation = null;
    public static int height = 0;
    public static Typeface iranSansBold = null;
    public static LayoutInflater layoutInflater = null;
    public static Animation leftAnim = null;
    public static int marketIndex = 1;
    public static String nativeBannerTapsellPlus = "5be59b3769013f0001bae3f4";
    public static String packageName = null;
    public static Resources resources = null;
    public static String rewardedVideoTapselPlus = "5be53d375b1b0300016ea025";
    public static Animation rightAnim = null;
    public static Animation scaleAnim = null;
    public static Animation scaleBigFadeAnim = null;
    public static Animation scale_fade_anim = null;
    public static Animation shakeAnimation = null;
    public static Animation shakeInfiniteAnimation = null;
    public static Animation slide_in_left = null;
    public static Animation slide_in_right = null;
    public static Animation slide_out_left = null;
    public static Animation slide_out_right = null;

    public static Animation vibrateAnim;
    public static Animation vibrateAnim2;
    public static int width;
    public static WindowManager wm;
    public Display display;
    boolean is_start_service = false;
    Intent play_music;
    private SharedPreferences prefs;

    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        resources = getResources();
        app = this;
        ads.pushe(this);

        fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in_longer);
        fadeOutAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_out);
        expandMore = AnimationUtils.loadAnimation(context, R.anim.expand_big_more);
        expandLess = AnimationUtils.loadAnimation(context, R.anim.expand_less);
        enterItemAnim = AnimationUtils.loadAnimation(context, R.anim.enter_item);
        expandBigAnim = AnimationUtils.loadAnimation(context, R.anim.expand_big_animation);
        expandInfinite = AnimationUtils.loadAnimation(context, R.anim.expand_infinite);
        shakeAnimation = AnimationUtils.loadAnimation(context, R.anim.shake);
        enterJumpAnim = AnimationUtils.loadAnimation(context, R.anim.enter_jump);
        shakeInfiniteAnimation = AnimationUtils.loadAnimation(context, R.anim.shake_infinite);
        vibrateAnim = AnimationUtils.loadAnimation(context, R.anim.vibrate_anim);
        exampleAnim = AnimationUtils.loadAnimation(context, R.anim.drop_anim);
        expand1 = AnimationUtils.loadAnimation(context, R.anim.expand_1);
        expand2 = AnimationUtils.loadAnimation(context, R.anim.expand_2);
        expand3 = AnimationUtils.loadAnimation(context, R.anim.expand_3);
        expand4 = AnimationUtils.loadAnimation(context, R.anim.expand_4);
        scaleAnim = AnimationUtils.loadAnimation(context, R.anim.scale_anim);
        expandReverseFoodAnim = AnimationUtils.loadAnimation(context, R.anim.expand_reverse_animal_food);
        leftAnim = AnimationUtils.loadAnimation(context, R.anim.left_gallery_anim);
        rightAnim = AnimationUtils.loadAnimation(context, R.anim.right_gallery_anim);
        slide_in_left = AnimationUtils.loadAnimation(context, R.anim.slide_in_left);
        slide_out_left = AnimationUtils.loadAnimation(context, R.anim.slide_out_left);
        slide_in_right = AnimationUtils.loadAnimation(context, R.anim.slide_in_right);
        slide_out_right = AnimationUtils.loadAnimation(context, R.anim.slide_out_right);
        scale_fade_anim = AnimationUtils.loadAnimation(context, R.anim.scale_fade_anim);
        clickAnim = AnimationUtils.loadAnimation(context, R.anim.click_anim);
        click_anim_fast = AnimationUtils.loadAnimation(context, R.anim.click_anim_fast);
        scaleBigFadeAnim = AnimationUtils.loadAnimation(context, R.anim.scale_big_fade_anim);
        dropBounceAnim = AnimationUtils.loadAnimation(context, R.anim.drop_bounce_anim);
        vibrateAnim2 = AnimationUtils.loadAnimation(context, R.anim.vibrate_anim2);
        packageName = getPackageName();
        wm = (WindowManager) context.getSystemService("window");
        layoutInflater = (LayoutInflater) context.getSystemService("layout_inflater");
        iranSansBold = Typeface.createFromAsset(getAssets(), "fonts/iran_sans_bold.ttf");
        Display defaultDisplay = wm.getDefaultDisplay();
        this.display = defaultDisplay;
        width = defaultDisplay.getWidth();
        height = this.display.getHeight();
    }









    private boolean internetConnection() {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        NetworkInfo networkInfo = connectivityManager.getNetworkInfo(1);
        if (networkInfo != null && networkInfo.isConnectedOrConnecting()) {
            return true;
        }
        NetworkInfo networkInfo2 = connectivityManager.getNetworkInfo(0);
        if (networkInfo2 != null && networkInfo2.isConnectedOrConnecting()) {
            return true;
        }
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        if (activeNetworkInfo == null || !activeNetworkInfo.isConnectedOrConnecting()) {
            return false;
        }
        return true;
    }

    public void tryToStopPlayer() {
        if (this.is_start_service) {
            context.stopService(this.play_music);
            this.is_start_service = false;
        }
    }

    public void playMp(String str, boolean z) {
        if (this.is_start_service) {
            context.stopService(this.play_music);
            this.is_start_service = false;
        }
        Intent intent = new Intent(context, PlayMusic.class);
        this.play_music = intent;
        intent.putExtra("SOUNDNAME", str);
        context.startService(this.play_music);
        this.is_start_service = true;
    }

/*    public void shareApp(Activity activity) {
        String str;
        int i = marketIndex;
        if (i == 1) {
            str = getString(R.string.share_text) + "\n" + getString(R.string.share_link_bazaar);
        } else if (i == 2) {
            str = getString(R.string.share_text) + "\n" + getString(R.string.share_link_myket);
        } else if (i == 3) {
            str = getString(R.string.share_text) + "\n" + getString(R.string.share_link_IA);
        } else if (i != 5) {
            str = "";
        } else {
            str = getString(R.string.share_text) + "\n" + getString(R.string.share_link_char);
        }
        Intent intent = new Intent("android.intent.action.SEND");
        intent.setType("text/plain");
        intent.putExtra("android.intent.extra.TEXT", str.replace('-', 10));
        intent.addFlags(268435456);
        activity.startActivity(Intent.createChooser(intent, getString(R.string.share)));
    }*/

  /*  public void join(String str) {
        Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https://telegram.me/" + str));
        intent.setFlags(268435456);
        startActivity(intent);
    }

    public void startShopActivity(Activity activity) {
        Intent intent = new Intent(activity, FirstActivity.class);
        intent.addFlags(268435456);
        startActivity(intent);
    }*/
}
